<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>登录</title>
	<link type="text/css" rel="stylesheet" href="css/login.css">
	<script type="text/javascript" src="miniui/jquery.min.js"></script>
	<script type="text/javascript" src="layer-v3.2.0/layer/layer.js"></script>
	<script type="text/javascript" src="myjs/util.js"></script>
</head>

<body style="overflow:hidden">
	<div class="pagewrap">
		<div class="main">
			<div class="header">

			</div>
			<div class="content">
				<div class="con_left"></div>
				<div class="con_right">
					<div class="con_r_top">
						<a href="javascript:;" class="right"
							style="width: 360px; color: rgb(51, 51, 51); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(46, 85, 142);">登录</a>
					</div>
					<!-- <div class="con_r_top"> -->
					<!-- <a href="javascript:;" class="left"
							style="color: rgb(255, 130, 130); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(222, 222, 222);">扫码直达</a> -->
					<!-- <a href="javascript:;" class="right"
							style="color: rgb(51, 51, 51); border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: rgb(46, 85, 142);">登录管理</a>
					</div> -->
					<ul>
						<!-- <li class="con_r_left" style="display: none;">
							<div class="erweima">
								<div class="qrcode">
									<div id="output" style="width: 100%; position: relative">
										<img src="http://hovertree.com/texiao/jquery/13/2weima.png"
											style="width: 174px; height: 174px">
									</div>
								</div>
							</div>
							<div style="height: 70px">
								<p>扫码上网 安全便捷</p>
							</div>
						</li> -->


						<li class="con_r_right" style="display: block;">
							<form name="form1" autocomplete="off">
								<div class="user">
									<div>
										<span class="user-icon"></span>
										<input type="text" id="username" name="username" placeholder="输入账号" value="">
									</div>

									<div>
										<span class="mima-icon"></span>
										<input type="password" id="password" name="password" placeholder="输入密码"
											value="">
									</div>

									<!-- <div>
										<span class="yzmz-icon"></span>
										<input id="vdcode" type="text" name="validate" placeholder="　验证码" value=""
											style=" width:150px;">

										<img style="cursor: pointer; margin-top:8px;" id="imgHoverTreeCode"
											alt="看不清？点击更换" title="看不清？点击更换"
											src="http://hovertree.com/texiao/jquery/13/hovertreecheckcode.gif">
									</div> -->

								</div><br>
								<button id="btn_login" type="button">登 录</button>
							</form>
						</li>
					</ul>

				</div>

			</div>
		</div>
	</div>

</body>

</html>

<script type="text/javascript">

	$('#btn_login').on('click', function () {
		var username = $("#username").val();
		var password = $("#password").val();

		if (username == null || username === '') {
			layer.msg('用户名不能为空', {icon: 5});
		}else if (password == null || password === ''){
			layer.msg('密码不能为空',{icon: 5});
		}else {
			var data = {"username": username,"password": password};
			$.ajax({
				url: GatewayUrl() + "/user/login",
				type: 'post',
				contentType: "application/json",
				data: JSON.stringify(data),
				success: function(dt){
					if(dt.code === 200){
						var token = dt.data.tokenHead + dt.data.token;
						localStorage.setItem("token",token);

						$.ajax({
							url: GatewayUrl() + "/user/info/" + username,
							type: 'get',
							headers: {
								"Authorization": localStorage.getItem("token")
							},
							success: function(dt){
								if(dt.code === 200){
									localStorage.setItem("menu",JSON.stringify(dt.data.menu));
									localStorage.setItem("user",JSON.stringify(dt.data.user));
									location.href = "index.html";
								}
							}
						})
						
					}else{
						layer.msg(dt.message,{icon: 5});
					}
				}
			})
		}
	});
	
</script>